<!-- 基础信息 -->
<template>
  <div class="index">
    <a-form ref="refForm" :model="formData?.baseInfo" :rules="rules">
      <!-- <a-form-item field="userName" label="交接人员" required>
        <a-input
          v-model="formData.baseInfo.userName"
          placeholder=""
          allow-clear
          disabled
          style="width: 350px"
        />
      </a-form-item>
      <a-form-item field="name" label="工作交接表模板名称" required>
        <a-input
          v-model="formData.baseInfo.name"
          placeholder="请输入模板名称"
          allow-clear
          style="width: 350px"
        />
      </a-form-item> -->
      <a-form-item field="templateId" label="交接模板" required>
        <a-select
          v-model="formData.baseInfo.templateId"
          placeholder="请选择模板"
          style="width: 350px"
        >
          <a-option
            v-for="item in templateList"
            :key="item.id"
            :value="item.id"
            :label="item.name"
          ></a-option>
        </a-select>
      </a-form-item>
      <!-- <a-form-item field="remark" label="描述">
        <a-textarea
          style="width: 400px"
          v-model="formData.baseInfo.remark"
          placeholder="请输入"
          show-word-limit
          :max-length="300"
          :auto-size="{
            minRows: 5
          }"
          allow-clear
        />
      </a-form-item> -->
    </a-form>
  </div>
</template>
<script lang="ts" setup>
import { useVModel } from '@vueuse/core';
import { GetLeaveQuitList } from '@/apis/management/human/baseSetting/leaveSetting';

const props = withDefaults(
  defineProps<{
    data: any;
  }>(),
  {}
);
const emit = defineEmits(['update:visible', 'update:data', 'handleOk', 'save']);
const formData = useVModel(props, 'data', emit);

const rules = {
  name: {
    required: true,
    message: '请输入模板名称'
  },
  templateId: {
    required: true,
    message: '请选择模板'
  }
};

let templateList = ref([]);
const getData = async () => {
  try {
    const { content } = await GetLeaveQuitList({
      pageNumber: 0,
      pageSize: -1
    });
    templateList.value = content;
  } catch (error: unknown) {
    console.log(error);
  }
};
getData();

let refForm = ref();
const validate = async () => {
  const check = await refForm.value.validate();
  return check;
};

defineExpose({ formData, validate });
</script>
<style scoped lang="less">
.index {
}
</style>
